var express = require('express');
var router = express.Router();
const AdminUserControl = require("../control/AdminUserControl")
const multer = require("multer")
const path = require("path")
//自定义存储
const storage = multer.diskStorage({
    //自定义存储位置
    destination: function (req, res, cb) {
        cb(null, 'public/images/user')
    },
    //文件名字
    filename: function (req, file, cb) {
        const uniquFilename = Date.now() + '-' + Math.round(Math.random() * 1E9)
        //获取后缀
        const ext = path.extname(file.originalname)
        cb(null, uniquFilename + ext)
    }
})
const upload_img = multer({ storage: storage })
router.post('/', AdminUserControl.login_admin)
router.put('/', AdminUserControl.put_admin)
router.put('/renewal', AdminUserControl.put_renewal)
router.post('/upload', upload_img.single("file"), AdminUserControl.put_avatar)
router.get('/02jzyskykljbng', AdminUserControl.add_admin)
module.exports = router;
